home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Motorola Fax1&ARA&Data < prev    next >
Text File  |  1995-05-22  |  7KB  |  368 lines

  1. ! Version 3.1.4
  2. !
  3. !$ Use this script with Motorola Power 28.8 modems
  4. !$ Supports: fax class 1, ARA and regular data incoming calls.
  5.  
  6. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1","Always"="2") "1"
  7. ^3 Speaker Volume:        = Enum("Low"="1","Medium"="2","High"="3") "2"
  8. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  9. ^5 Port Speed:        = Enum("9600","19200","38400","57600") "38400"
  10. ^6 Handshake wires:   = Bool("Both"="¥Q3&D0","CTS only"="¥Q2&D2") "¥Q2&D2"
  11. ! ------------------------------------------
  12. ! Resetting the modem:
  13. ! ------------------------------------------
  14. @Hangup
  15.   SetTries 2
  16.   Flush
  17.   HsReset 0,0,17,19,0,0
  18.   DtrSet
  19. !
  20. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  21. ! to enter the command mode
  22. !
  23. @Label 1
  24.   matchclr
  25.   matchstr 1 2 "OK¥r¥n"
  26.   write "AT&F¥r"
  27.   matchread 20
  28.   ChrDelay 1
  29.   Write "+++"
  30.   ChrDelay 0
  31.   DtrClear
  32.   SBreak
  33.   DtrSet
  34. !
  35.   DecTries
  36.   IfTries 0 1
  37. !
  38. ! OSErr -6019 "Modem error - the modem is not responding"
  39. !
  40.   exit -6019
  41. @Label 2
  42.   write "AT+FCLASS=0¥r"
  43.   Jsr 100
  44.   write "AT+FAA=0¥r"
  45.   Jsr 100
  46.   exit 0
  47.  
  48. ! ------------------------------------------
  49. !    Receiving incoming calls
  50. ! ------------------------------------------
  51. @ANSWER
  52. !
  53. ! Set the modem preferred speed first
  54. !
  55.   SerReset 19200,0,8,1
  56.   Jsr 80
  57.  
  58. @Label 10
  59. !
  60. ! Set the common options
  61.   Jsr 70
  62. !
  63. ! Set the communication options:
  64. ! ・ - disabled: ¥N0: Normal connection (for ARA)
  65. ! ・ ¥V2:  report connection speed
  66.   Write "AT¥¥V2¥r"
  67.   Jsr 100
  68. !
  69. ! Set Fax mode
  70. !
  71.   Write "AT+FCLASS=0¥r"
  72.   Jsr 100
  73.   Write "AT+FAA=1¥r"
  74.   Jsr 100
  75. !
  76. ! Tell the modem to determine the type of the incoming call
  77. ! Fetch the tube after ^4 rings
  78. !
  79.   Write "ATS0=^4V0¥r"
  80.   Jsr 110
  81. !
  82. ! Everything is ready - let's sit and wait for a call
  83. ! We'll wait for 2 minutes, then reinitiate the modem
  84. !
  85.   Note "Waiting for a fax/ARA/data call?"
  86.   MatchClr
  87.   MatchStr 1 15 "15¥r"
  88.   MatchStr 2 14 "17¥r"
  89.   matchstr 3 13 "2¥r"
  90.   matchstr 4 57 "1¥r"
  91.   matchstr 5 12 "3¥r"
  92.   matchstr 6 12 "8¥r"
  93.   matchstr 7 12 "7¥r"
  94. @Label 11
  95.   Matchread 1200
  96. @Label 12
  97.   Note "Tuning again?"
  98.   Write "ATV1¥r"
  99.   Jsr 100
  100.   Jump 10
  101. @Label 13
  102.   Note "Ring?"
  103.   jump 11
  104. @Label 14
  105.   Note "Fax tones detected?"
  106. ! IfStr 7 11 "V"
  107. ! SetSpeed 19200
  108.   Jump 11
  109.  
  110. @Label 15
  111.   Note "Data call?"
  112. ! SetSpeed Val("^5")
  113. !  ChrDelay 1
  114.    Write "ATV1O0¥r"
  115. !  ChrDelay 0
  116.   MatchClr
  117.   MatchStr 1 16 "¥r¥nCONNECT ^$¥r¥n"
  118.   MatchRead 20
  119.   exit -6019
  120. @Label 16
  121.   SetVar B "^$"
  122.   Jump 20
  123.  
  124. !
  125. ! Data connection has been established (we read "CONNECT")
  126. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  127. ! if it was an incoming call, put the "RING" before the "CONNECT"
  128. !
  129. @Label 20
  130.   IfOpen "Data" 21
  131.   Jump 30
  132. @Label 21
  133.   IfOpen "ARA" 22
  134.   Jump 35
  135. @Label 22
  136.   Note "Waiting for an ARA frame"
  137.   MatchClr
  138.   MatchStr 1 23 "^$¥r"
  139.   MatchStr 2 28 "¥08¥01¥03¥14¥04¥03¥00¥08¥250¥16¥03"
  140.   MatchStr 3 29 "¥01¥27¥02¥29¥01¥02¥01¥06"
  141.   MatchRead 60
  142.   Jump 24
  143. @Label 23
  144.   QueueInput "^$¥r"
  145. @Label 24
  146.   Note "Non-ARA call"
  147.   Jump 35
  148.  
  149. @Label 28
  150.   Note "ARA 1.0 call"
  151.   Jump 30
  152. @Label 29
  153.   Note "ARA 2.0 call"
  154.   Jump 30
  155.  
  156. @Label 30
  157.   QueueInput "¥r¥nCARRIER ^B¥r¥n"
  158.   QueueInput "¥r¥nRING¥r¥n"
  159.   Attach "ARA" (DTR)
  160.  
  161. @Label 35
  162.   GetSReg C "DATA" 4
  163.   QueueInput "¥r^CCONNECT ^B¥r^C"
  164.   ifOriginate 36
  165.   QueueInput "¥r^CRING¥r^C"
  166. @Label 36
  167.   Attach "Data" (DTR,Escape,Break)
  168.  
  169. ! ------------------------------------------
  170. ! Originating a call through the "ARA" subport
  171. ! ------------------------------------------
  172. @ORIGINATE "ARA"
  173.   SerReset Val("^5"),0,8,1
  174.   Jsr 80
  175. !
  176. ! Set the common options
  177. !
  178.   Jsr 70
  179. !
  180. ! Set the Data mode:
  181. ! ・ ¥N0:Normal connection (no compression, correction - for ARA)
  182. ! ・ S7:  time-out (90 sec) for long-distance calls
  183. ! ・ ¥V2: report connection rate
  184. !
  185.   Write "AT¥¥N0S7=90¥¥V2¥r"
  186.   Jsr 100
  187. !
  188. ! Emit the ARA script commands ("Xnn")
  189.   Jsr 60
  190. !
  191. ! Prepare to receive all error result codes, dial the number
  192. !
  193.   Jsr 90
  194.   MatchStr 1 55 "¥r¥nCONNECT ^$¥r¥n"
  195.   MatchRead 1000
  196.   Write "¥r"
  197.   Exit -6019
  198. @Label 55
  199.   QueueInput "¥r¥nCARRIER ^$¥r¥n"
  200.   Attach "ARA" (DTR)
  201.  
  202. ! ------------------------------------------
  203. ! Originating a call through the "DATA" subport
  204. ! ------------------------------------------
  205. @ORIGINATE "Data"
  206.   SerReset Val("^5"),0,8,1
  207.   Jsr 80
  208. !
  209. ! Set the common options
  210. !
  211.   Jsr 70
  212. !
  213. ! Set the Data mode:
  214. ! ・ ¥N7: Auto-reliable
  215. ! ・ S7:  time-out (90 sec) for long-distance calls
  216. ! ・ ¥V0: report port speed
  217. !
  218.   Write "AT¥¥N7S7=90¥¥V0¥r"
  219.   Jsr 100
  220. !
  221. ! Emit the Data commands
  222.   Jsr 60
  223. !
  224. ! Prepare to receive all error result codes, dial the number
  225. !
  226.   Jsr 90
  227.   MatchStr 1 56 "¥r¥nCONNECT "
  228.   MatchRead 1000
  229.   Write "¥r"
  230.   Exit -6019
  231. @Label 56
  232.   QueueInput "¥r¥nCONNECT "
  233.   Attach "Data" (DTR,Escape,Break)
  234.  
  235. ! ------------------------------------------
  236. ! Originating a call through the "Fax" subPort
  237. ! ------------------------------------------
  238. @ORIGINATE "Fax"
  239. !
  240. ! Set the "Fax" speed
  241. !
  242.   SerReset 19200,0,8,1
  243.   Jsr 80
  244. !
  245. ! Set the common options
  246. !
  247.   Jsr 70
  248. !
  249. ! Set the Fax mode
  250. ! ¥Q1: Xon/Xoff handshake
  251. ! &S0: DSR always on
  252. !
  253.   Write "AT&S0¥¥Q1+FCLASS=1¥r"
  254.   Jsr 100
  255. !
  256. ! Now emit all commands that the application has sent to that port,
  257. ! except "FCLASS", etc
  258. !
  259.   EmitClear "+FCLASS","V","E"
  260.   Jsr 60
  261.   Write "ATV0¥r"
  262.   Jsr 110
  263. !
  264. ! Prepare to receive all error result codes, dial the number
  265. !
  266.   MatchClr
  267.   MatchStr 01 57 "1¥r"
  268.   MatchStr 13 93 "3¥r"
  269.   MatchStr 14 94 "8¥r"
  270.   MatchStr 15 92 "7¥r"
  271.   Write "ATD^1¥r"
  272.   HsReset *
  273.   MatchRead 900
  274.   Write "¥r"
  275.   Exit -6019
  276.  
  277. !
  278. ! Fax connection has been established (we read "FAX")
  279. ! Put the +FCON back to the buffer,
  280. ! if it was an incoming call, put the "RING" before the "+FCON"
  281. ! Attach the "Fax" subPort
  282. !
  283. @Label 57
  284.   QueueInput "1¥r"
  285. ! IfStr 7 58 "V"
  286.   SetSpeed 19200
  287. @Label 58
  288.   ifOriginate 59
  289.   QueueInput "2¥r2¥r"
  290. @Label 59
  291.   Attach "Fax" (Reset(2400),IdleLimit=30)
  292.  
  293. !
  294. ! This section emits all modem commands sent from the client application
  295. ! For each set of commands the "OK" answer is awaited
  296. !
  297. @Label 60
  298.   EmitStart
  299. @Label 61
  300.   EmitCommand 62
  301.   Jsr 100
  302.   Jump 61
  303. @Label 62
  304.   return
  305. !
  306. ! This section initiates the modem before ANSWER and ORIGINATEs:
  307. ! extended responses + connect at the highest rate + speaker control +
  308. ! reset on Dtr drop + DCD valid
  309. ! Verbal responses mode, no echo
  310. !
  311. @Label 70
  312.   Write "ATX4M^2L^3^6&C1V1E0¥r"
  313.   Jsr 100
  314.   return
  315.  
  316. !
  317. ! This section syncronize the modem after the serial port speed switching
  318. !
  319. @Label 80
  320.   ChrDelay 1
  321.   Write "AT¥r"
  322.   ChrDelay 0
  323.   Jsr 100
  324.   return
  325. !
  326. ! Prepare to receive error result codes, send the dialing command and
  327. ! set the user's handshake mode
  328. !
  329. @Label 90
  330.   MatchClr
  331.   MatchStr 2 91 "NO DIALTONE¥r¥n"
  332.   MatchStr 3 92 "BUSY¥r¥n"
  333.   MatchStr 4 93 "NO CARRIER¥r¥n"
  334.   MatchStr 5 94 "NO ANSWER¥r¥n"
  335.   Write "ATD^1¥r"
  336.   HsReset *
  337.   return
  338. @Label 91
  339.   exit -6020
  340. @Label 92
  341.   exit -6022
  342. @Label 93
  343.   exit -6021
  344. @Label 94
  345.   exit -6023
  346. !
  347. ! Processing the AT command:
  348. ! OK -> proceed
  349. ! ERROR or TimeOut ->exit -6019
  350. ! It can be called AFTER the "Write" command, since LineShare buffers input
  351. !
  352. @Label 100
  353.   MatchClr
  354.   MatchStr 1 103 "¥r¥nOK¥r¥n"
  355.   MatchStr 2 102 "¥r¥nERROR¥r¥n"
  356. @Label 101
  357.   MatchRead 20
  358. @Label 102
  359.   Exit -6019
  360. @Label 103
  361.   return
  362.  
  363. @Label 110
  364.   MatchClr
  365.   MatchStr 1 103 "0¥r"
  366.   MatchStr 2 102 "4¥r"
  367.   Jump 101
  368.